{% extends "base.html" %}

{% block content %}
    <div class="post-detail">
        <h1>{{ post['title'] }}</h1>
        
        <div class="post-meta">
            <span class="author">作者: {{ post['author_name'] }}</span>
            <span class="time">发帖时间: {{ post['create_time'] }}</span>
            <span class="reply-num">回复数: {{ post['reply_num'] }}</span>
        </div>
        
        <div class="post-content">
            <!-- 主楼内容 -->
            {% if main_content %}
                <div class="floor floor-1">
                    <div class="floor-header">
                        <span class="floor-num">1楼</span>
                        <span class="user-id">用户ID: {{ main_content['user_id'] }}</span>
                        <span class="time">{{ main_content['timestamp'] | datetime }}</span>
                    </div>
                    <div class="floor-content">
                        {{ main_content['content'] | safe }}
                        {% if main_content['img_hashes'] %}
                            <div class="images">
                                {% for hash in main_content['img_hashes'].split(',') %}
                                    <img src="{{ hash | image_url }}" alt="图片">
                                    <!--<img src="{{ url_for('static', filename='images/' + hash + '.jpg') }}" alt="图片">-->
                                {% endfor %}
                            </div>
                        {% endif %}
                    </div>
                </div>
            {% endif %}

            <!-- 其他主楼层 -->
            {% for floor in main_floors %}
                {% if floor['floor'] != 1 %}
                    <div class="floor floor-{{ floor['floor'] }}">
                        <div class="floor-header">
                            <span class="floor-num">{{ floor['floor'] }}楼</span>
                            <span class="user-id">用户ID: {{ floor['user_id'] }}</span>
                            <span class="time">{{ floor['timestamp'] | datetime }}</span>
                        </div>
                        <div class="floor-content">
                            {{ floor['content'] | safe }}
                            {% if floor['img_hashes'] %}
                                <div class="images">
                                    {% for hash in floor['img_hashes'].split(',') %}
                                        <img src="{{ hash | image_url }}" alt="图片">
                                        <!--<img src="{{ url_for('static', filename='images/' + hash + '.jpg') }}" alt="图片">-->
                                    {% endfor %}
                                </div>
                            {% endif %}

                            <!-- 楼中楼回复 -->
                            {% if floor['post_id'] in replies_by_post %}
                                <div class="sub-replies">
                                    {% for reply in replies_by_post[floor['post_id']] %}
                                        <div class="sub-reply">
                                            <div class="sub-reply-header">
                                                <span class="user-id">用户ID: {{ reply['user_id'] }}</span>
                                                <span class="time">{{ reply['timestamp'] | datetime }}</span>
                                            </div>
                                            <div class="sub-reply-content">
                                                {{ reply['content'] | safe }}
                                                {% if reply['img_hashes'] %}
                                                    <div class="images">
                                                        {% for hash in reply['img_hashes'].split(',') %}
                                                            <img src="{{ hash | image_url }}" alt="图片">
                                                            <!--<img src="{{ url_for('static', filename='images/' + hash + '.jpg') }}" alt="图片">-->
                                                        {% endfor %}
                                                    </div>
                                                {% endif %}
                                            </div>
                                        </div>
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </div>
                    </div>
                {% endif %}
            {% endfor %}
        </div>

        <!-- 卦象信息部分保持不变 -->
        {% if gua_data %}
            <div class="gua-data">
                <!-- 原有卦象信息展示代码 -->
            </div>
        {% endif %}
    </div>
{% endblock %}